import axios from "axios";

const fixBaseUrl= "http://localhost:8082";
const fixRequest={
    loadFixes(fix,callBack){
        let url = fixBaseUrl + "/fix/list?";
        if(fix){
            if(fix.fixEncode){
                url += "&fixEncode=" + fix.fixEncode;
            }
            if(fix.fixName){
                url += "&fixName=" + fix.fixName;
            }
            if(fix.fixType){
                url += "&fixType=" + fix.fixType;
            }
        }
        axios.get(url)
            .then(res=>{
                callBack(res.data);
            })
    },
    insertFix(fix,callBack){
        let url = fixBaseUrl + "/fix/insert";
        axios.post(url,fix)
            .then(res=>{
                callBack(res.data);
            })
    },
    update(fix,callBack){
        let url  = fixBaseUrl + "/fix/update";
        axios.put(url,fix)
            .then(res=>{
                callBack(res.data);
            })
    },
    selectById(fixId,callBack){
        let url = fixBaseUrl + "/fix/selectById?fixId=" + fixId;
        axios.get(url)
            .then(res=>{
                callBack(res.data);
            })
    },
    delete(fixId,callBack){
        let url = fixBaseUrl + "/fix/delete?fixId=" + fixId;
        axios.delete(url)
            .then(res=>{
                callBack(res.data);
            })
    }
}

export default fixRequest;
